home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************************
-
- Gnucleus - A node application for the Gnutella network
- Copyright (C) 2000 John Marshall
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- For support, questions, comments, etc...
- E-Mail:
- swabby@c0re.net
-
- Address:
- 21 Cadogan Way
- Nashua, NH, USA 03062
-
- ********************************************************************************/
-
- // PrefDownload.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "Gnucleus.h"
- #include "GnucleusDoc.h"
- #include "PrefDownload.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CPrefDownload property page
-
- IMPLEMENT_DYNCREATE(CPrefDownload, CPropertyPage)
-
- CPrefDownload::CPrefDownload() : CPropertyPage(CPrefDownload::IDD)
- {
- Doc = NULL;
-
- //{{AFX_DATA_INIT(CPrefDownload)
- //}}AFX_DATA_INIT
- }
-
- CPrefDownload::~CPrefDownload()
- {
- }
-
- void CPrefDownload::DoDataExchange(CDataExchange* pDX)
- {
- CPropertyPage::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CPrefDownload)
- DDX_Control(pDX, IDC_CHECK_RESUME, m_chkResume);
- DDX_Control(pDX, IDC_EDIT_TIMEOUT_DL, m_ebTimeoutDL);
- DDX_Control(pDX, IDC_CHECK_CLEAR_DL, m_chkClearDL);
- DDX_Control(pDX, IDC_EDIT_SAVEDIR, m_ebSaveDir);
- DDX_Control(pDX, IDC_CHECK_MAX_DL, m_chkMaxDL);
- DDX_Control(pDX, IDC_EDIT_MAX_DL, m_ebMaxDL);
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(CPrefDownload, CPropertyPage)
- //{{AFX_MSG_MAP(CPrefDownload)
- ON_EN_CHANGE(IDC_EDIT_SAVEDIR, OnChangeEditSavedir)
- ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
- ON_BN_CLICKED(IDC_CHECK_MAX_DL, OnCheckMaxDl)
- ON_EN_CHANGE(IDC_EDIT_MAX_DL, OnChangeEditMaxDl)
- ON_BN_CLICKED(IDC_CHECK_CLEAR_DL, OnCheckClearDl)
- ON_EN_CHANGE(IDC_EDIT_TIMEOUT_DL, OnChangeEditTimeoutDl)
- ON_BN_CLICKED(IDC_CHECK_RESUME, OnCheckResume)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CPrefDownload message handlers
-
- BOOL CPrefDownload::OnInitDialog()
- {
- CPropertyPage::OnInitDialog();
-
- Doc = (CGnucleusDoc *) ((CGnucleusApp *) AfxGetApp())->MasterDoc;
-
- // Save downloads setting
- m_ebSaveDir.SetWindowText(Doc->m_DownloadDir);
-
- // Max simultaneous downloads
- if(Doc->m_MaxDownloads)
- {
- m_chkMaxDL.SetCheck(1);
- m_ebMaxDL.SetWindowText( DWrdtoStr(Doc->m_MaxDownloads) );
- }
- else
- {
- m_ebMaxDL.SetWindowText("Unlim.");
- m_ebMaxDL.EnableWindow(FALSE);
- }
-
- // Auto clear downloads
- if(Doc->m_AutoClearDL)
- m_chkClearDL.SetCheck(1);
-
- // Timeout of download length
- m_ebTimeoutDL.SetWindowText( DWrdtoStr(Doc->m_TimeoutDownload) );
-
- // Resume downloads
- if(Doc->m_ResumeDL)
- m_chkResume.SetCheck(1);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
-
- void CPrefDownload::OnChangeEditSavedir()
- {
- SetModified();
- }
-
- void CPrefDownload::OnButtonBrowse()
- {
- char *Directory = new char[255];
-
- LPBROWSEINFO Settings = new BROWSEINFO;
- Settings->hwndOwner = m_hWnd;
- Settings->pidlRoot = NULL;
- Settings->pszDisplayName = Directory;
- Settings->lpszTitle = "Save Downloads to...";
- Settings->ulFlags = BIF_RETURNONLYFSDIRS;
- Settings->lpfn = NULL;
- Settings->lParam = NULL;
- Settings->iImage = NULL;
-
- LPCITEMIDLIST FolderID = SHBrowseForFolder(Settings);
- delete Settings;
-
-
- if(FolderID) // if cancel was hit, leave the current directory setting
- {
- SHGetPathFromIDList(FolderID, Directory);
-
- CString File = Directory;
-
- m_ebSaveDir.SetWindowText(File);
-
- SetModified();
- }
-
- delete [] Directory;
- }
-
- void CPrefDownload::OnCheckMaxDl()
- {
- if(m_chkMaxDL.GetCheck())
- {
- m_ebMaxDL.SetWindowText( DWrdtoStr(Doc->m_MaxDownloads) );
- m_ebMaxDL.EnableWindow();
- }
- else
- {
- m_ebMaxDL.SetWindowText("Unlim.");
- m_ebMaxDL.EnableWindow(FALSE);
- }
-
- SetModified();
- }
-
- void CPrefDownload::OnChangeEditMaxDl()
- {
- SetModified();
- }
-
- void CPrefDownload::OnCheckClearDl()
- {
- SetModified();
- }
-
- void CPrefDownload::OnChangeEditTimeoutDl()
- {
- SetModified();
- }
-
- void CPrefDownload::OnCheckResume()
- {
- SetModified();
- }
-
- BOOL CPrefDownload::OnApply()
- {
- CString store;
-
- // Save downloads setting
- m_ebSaveDir.GetWindowText(store);
- Doc->m_DownloadDir = store;
-
- // Max simultaneous downloads
- if(m_chkMaxDL.GetCheck())
- {
- m_ebMaxDL.GetWindowText(store);
-
- if(store != "")
- Doc->m_MaxDownloads = atoi(store);
- }
- else
- Doc->m_MaxDownloads = 0;
-
- // Auto clear downloads
- if(m_chkClearDL.GetCheck())
- Doc->m_AutoClearDL = 1;
- else
- Doc->m_AutoClearDL = 0;
-
- // Timeout of download length
- m_ebTimeoutDL.GetWindowText(store);
-
- if(store != "")
- Doc->m_TimeoutDownload = atoi(store);
-
- // Resume downloads
- if(m_chkResume.GetCheck())
- Doc->m_ResumeDL = 1;
- else
- Doc->m_ResumeDL = 0;
-
- return CPropertyPage::OnApply();
- }
-
-
-